package com.jee.listener;


import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

/**
 * Application Lifecycle Listener implementation class ListenerA
 *
 */
public class ListenerA implements ServletContextListener {

    /**
     * Default constructor. 
     */
    public ListenerA() {
    	System.out.println("------------------listener start--------------");
        System.out.println("coming in ListenerA's constructor...");
    }

	/**
     * @see ServletContextListener#contextInitialized(ServletContextEvent)
     */
    public void contextInitialized(ServletContextEvent event) {
    	ServletContext context = event.getServletContext();
    	System.out.println(context.getRealPath("/"));
    	System.out.println("coming in ListenerA's Init...");
			try {
				//使用newInstance()可以调用对象的构造进行初始化操作[多出2个异常需要捕获]
				Class.forName("com.jee.vo.Voa").newInstance();
			} catch (ClassNotFoundException e) {
				e.printStackTrace();
			} catch (InstantiationException e) {
				e.printStackTrace();
			} catch (IllegalAccessException e) {
				e.printStackTrace();
			}
    }
	/**
     * @see ServletContextListener#contextDestroyed(ServletContextEvent)
     */
    public void contextDestroyed(ServletContextEvent event) {
    	System.out.println("coming in ListenerA's Destroy...");
    }
	
}
